<?php 

//Connexion à la BDD
	include ("../commun_shop/utils/settings_bdd_shop.php"); mysql_connect($host_bd, $id_bd , $mdp_bd);
	mysql_select_db("vanadium");mysql_query("SET NAMES 'UTF8'");

$utilisateurs = mysql_query("SELECT * FROM utilisateurs") or die(mysql_error()) ;

while ($compte = mysql_fetch_array($utilisateurs))
{
	$id = $compte['id_consommateur'];
	$montant = mysql_query("SELECT solde FROM utilisateurs WHERE id_consommateur ='$id'") or die(mysql_error()) ;
	$montant = mysql_fetch_array($montant);
	$somme = mysql_query("SELECT SUM( montant )FROM historique WHERE id_consommateur = '$id'") or die(mysql_error()) ;
	$somme = mysql_fetch_array($somme);
	
	$delta = $montant[0]-$somme[0];
	$total = $total+$delta;
}

echo $total;
?>
